import { InjectionKey } from "vue";
import { useStore as baseUserStore, createStore, Store } from "vuex";
import user from './modules/user';
interface State {
    userName: string,
    user: {
        token: string,
        userInfo: object | null
    }
}

export const key: InjectionKey<Store<State>> = Symbol();

export const store = createStore({
    modules: {
        user: user
    },
    getters: {
        hasLogin: (state: any) => {
            return Boolean(state.user.token)
        }
    }
})

export function useStore() {
    return baseUserStore(key);
}